package com.edocbase.desktopserver.impl.jetty;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.edocbase.desktopserver.IDesktopRequest;

public class DesktopHttpRequest implements IDesktopRequest {
	private HttpServletRequest request = null;

	public DesktopHttpRequest(HttpServletRequest request) {
		super();
		this.request = request;
	}

	public Object getAttribute(String arg0) {
		return request.getAttribute(arg0);
	}

	public String getParameter(String arg0) {
		return request.getParameter(arg0);
	}

	public void removeAttribute(String arg0) {
		request.removeAttribute(arg0);
	}

	public void setAttribute(String arg0, Object arg1) {
		request.setAttribute(arg0, arg1);
	}

	@Override
	public String getPath() {
		return request.getServletPath();
	}

	@Override
	public Map<String, String> getParameters() {
		Map<String,String> rntParas = new HashMap<String, String>();
		Enumeration<String> names = request.getParameterNames();
		for (;names.hasMoreElements();){
			String key = names.nextElement();
			rntParas.put(key, getParameter(key));
		}
		
		return rntParas;
	}


}
